using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MyMes.Dto;
using MyMES.IServices.ArrivalNotices;
using System.Threading.Tasks;
using VOL.Core.Controllers.Basic;
using VOL.Core.Filters;
using VOL.Core.Utilities.Response;
using VOL.Entity.AttributeManager;
using VOL.Entity.DomainModels.Repository;

namespace VOL.WebApi.Controllers.MyMES
{
    /// <summary>
    /// 到货通知单管理控制器
    /// </summary>
    [Route("api/ArrivalNotice")]
    [ApiController]
    [AllowAnonymous]
    [PermissionTable(Name = "ArrivalNotice")]
    public class ArrivalNoticeController : ApiBaseController<IArrivalNoticeService>
    {
        private readonly IArrivalNoticeService _arrivalNoticeService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="arrivalNoticeService">到货通知单服务</param>
        public ArrivalNoticeController(IArrivalNoticeService arrivalNoticeService)
            : base(arrivalNoticeService)
        {
            _arrivalNoticeService = arrivalNoticeService;
        }

        /// <summary>
        /// 获取到货通知单列表
        /// </summary>
        /// <param name="dto">查询条件</param>
        /// <returns>到货通知单列表</returns>
        [HttpPost("GetShipmentsModelList")]

        public async Task<ActionResult> GetShipmentsModelList([FromBody] GetArrivalNoticeDto dto)
        {
            return Json(await _arrivalNoticeService.GetShipmentsModelList(dto));
        }

        /// <summary>
        /// 创建到货通知单
        /// </summary>
        /// <param name="entity">到货通知单实体</param>
        /// <returns>操作结果</returns>
        [HttpPost("CreateShipmentsModel")]
        public async Task<WebResponseContent> CreateShipmentsModel([FromBody] ArrivalNotice entity)
        {
            return await _arrivalNoticeService.CreateShipmentsModel(entity);
        }

        /// <summary>
        /// 更新到货通知单
        /// </summary>
        /// <param name="entity">到货通知单实体</param>
        /// <returns>操作结果</returns>
        [HttpPost("UpdateShipmentsModel")]
        public async Task<WebResponseContent> UpdateShipmentsModel([FromBody] ArrivalNotice entity)
        {
            return await _arrivalNoticeService.UpdateShipmentsModel(entity);
        }

        /// <summary>
        /// 删除到货通知单
        /// </summary>
        /// <param name="ids">到货通知单ID列表，以逗号分隔的字符串</param>
        /// <returns>操作结果</returns>
        [HttpPost("DelShipments")]
        public async Task<WebResponseContent> DelShipments([FromQuery] string ids)
        {
            return await _arrivalNoticeService.DelShipments(ids);
        }
    }
} 